<template>
  <div class="container">
    <div class="app-container">
      <el-input v-model="pageParams.poleName" size="mini" placeholder="请输入一体杆名称" style="width: 200px; margin-right: 10px;" />
      <el-input v-model="pageParams.poleNumber" size="mini" placeholder="请输入一体杆编号" style="width: 200px; margin-right: 10px;" />
      <el-select v-model="pageParams.poleStatus" size="mini" placeholder="请选择运行状态" style="width: 200px; margin-right: 10px;">
        <el-option size="mini" label="正常" value="1" />
        <el-option size="mini" label="异常" value="0" />
      </el-select>
      <el-button size="mini" type="primary" @click="search">查询</el-button>
      <el-row style="margin-top: 20px;">
        <el-button size="mini" type="primary">添加一体杆</el-button>
        <el-button style="padding-left: 20px;padding-right: 20px;" size="mini" type="text">批量删除</el-button>
      </el-row>
      <el-table :data="list" style="width: 100%; margin-top: 20px;">
        <el-table-column align="center" type="selection" width="55" />
        <el-table-column align="center" type="index" label="序号" width="50" />
        <el-table-column align="center" prop="poleName" label="一体杆名称" />
        <el-table-column align="center" prop="poleNumber" label="一体杆编号" />
        <el-table-column align="center" prop="poleIp" label="一体杆IP" />
        <el-table-column align="center" prop="areaName" label="安装区域" />
        <el-table-column align="center" label="一体杆类型" prop="poleType">
          <template v-slot="{ row }">
            {{ row.poleType == "entrance" ? '入口' : (row.poleType == "export" ? '出口' : '未知') }}
          </template>
        </el-table-column>
        <el-table-column align="center" label="运行状态" prop="poleStatus">
          <template v-slot="{ row }">
            {{ row.poleStatus ? '正常' : '异常' }}
          </template>
        </el-table-column>
        <el-table-column label="操作" width="150">
          <template>
            <el-button size="mini">编辑</el-button>
            <el-button size="mini">删除</el-button>
          </template>
        </el-table-column>
      </el-table>

      <el-row type="flex" justify="end">
        <el-pagination
          :current-page="pageParams.page"
          :page-sizes="[10, 20, 50, 100]"
          :page-size="pageParams.pageSize"
          layout="total, sizes, prev, pager,jumper, next"
          :total="total"
          @current-change="changePage"
        />
      </el-row>
    </div>
  </div>
</template>
<script>
import { getIntgratedAPI } from '@/api'

export default {
  name: 'IntegratedBarrierManagement',
  data() {
    return {
      pageParams: {
        poleStatus: '',
        poleNumber: '',
        poleName: '',
        page: 1,
        pageSize: 10,
        status: ''
      },
      list: [],
      total: 0
    }
  },
  created() {
    this.getIntgrated()
  },
  methods: {
    async getIntgrated() {
      const { rows, total } = await getIntgratedAPI(this.pageParams)
      this.list = rows
      this.total = total
    },
    changePage(newPage) {
      this.pageParams.page = newPage
      this.getIntgrated()
    },
    search() {
      this.getIntgrated()
    }
  }
}
</script>
